use wasm_bindgen::prelude::*;

// Import the `window.alert` function from the Web.
#[wasm_bindgen]
extern "C" {
    fn alert(s: &str);
    #[wasm_bindgen(js_namespace = console)]
    fn log(s: &str);
}

#[wasm_bindgen]
#[derive(Debug, Default)]
pub struct Diagram {
    options: DefaultOptions,
}

#[wasm_bindgen]
#[derive(Debug, Default)]
pub struct DefaultOptions {
    id: String,
    title: String,
    data: Vec<Data>,
}

#[wasm_bindgen]
impl DefaultOptions {
    #[wasm_bindgen(constructor)]
    pub fn new() -> Self {
        Self::default()
    }
}

#[wasm_bindgen]
#[derive(Debug, Default)]
struct Data {
    id: String,
    title: String,
}

#[wasm_bindgen]
impl Diagram {
    #[wasm_bindgen(constructor)]
    pub fn new() -> Self {
        Self::default()
    }

    pub fn set_options(self, options: DefaultOptions) {
        log(&format!("{:?},--------", options));
    }
}
